const path = require('path');
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
    entry: {
        app: './app.ts'
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        publicPath: '/dist/',
        filename: 'js/[name].bundle.js',
        chunkFilename: 'js/[name].chunk.js'
    },
    module: {
        rules: [{
            test: /\.ts$/,
            use: 'ts-loader',
            exclude: /node_modules/
        }]
    },
    // require 文件时可省略后缀 .js 和 .ts
    resolve: {
        extensions: [' ', '.js', '.ts']
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new HtmlWebpackPlugin({
            title: 'Typescript',
            template: './index.html'
        })
    ],

    // 配置 webpack-dev-server
    devServer: {
        historyApiFallback: true,
        hot: true,
        inline: true,
        port: 9090, // 修改端口，一般默认是8080，
        contentBase: __dirname + '/dist'
    }
};